<template>
  <div class="banner">
    <el-carousel :interval="2000" :width="500" arrow="always"  :height="banH +'px'" >//:height设置自适应高度
      <el-carousel-item v-for="(item,index) in list_img" :key="index">
        <h3 class="h3">
          <img  :src="item.url" width="650" height="650" alt="" />
        </h3>
      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<script>
export default {
  name: "banner",
  data(){
    return{
      banH:560,
      list_img:[
        { url: require('../../assets/images/1.png') },
        { url: require('../../assets/images/2.png') },
        { url: require('../../assets/images/3.png') },
        { url: require('../../assets/images/4.png') },
      ]
    }
  },methods:{
    setbanH(){
      this.banH=500
    }
  },
  mounted() {

    this.setbanH()

    window.addEventListener('resize', () => {

      this.setbanH()

    }, false)
  },
}
</script>

<style scoped>
.banner {
  margin: 0 auto;
  width: 560px;
  height:560px;
}
.h3 {
  color: #475669;
  width: 650px;
  height: 650px;
  font-size: 18px;
  opacity: 0.75;

  margin: 0;
}
.el-carousel__item>h3>img{
  width: 560px;
  height: 560px;
}
.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n+1) {
  background-color: #d3dce6;
}

</style>